\(\int (a+i a \tan (c+d x))^2 (A+B \tan (c+d x)) \, dx\) [11]

   Optimal result
   Rubi [A] (verified)
   Mathematica [A] (verified)
   Maple [A] (verified)
   Fricas [A] (verification not implemented)
   Sympy [A] (verification not implemented)
   Maxima [A] (verification not implemented)
   Giac [B] (verification not implemented)
   Mupad [B] (verification not implemented)

Optimal result

Integrand size = 26, antiderivative size = 80 \[ \int (a+i a \tan (c+d x))^2 (A+B \tan (c+d x)) \, dx=2 a^2 (A-i B) x-\frac {2 a^2 (i A+B) \log (\cos (c+d x))}{d}-\frac {a^2 (A-i B) \tan (c+d x)}{d}+\frac {B (a+i a \tan (c+d x))^2}{2 d} \]

[Out]

2*a^2*(A-I*B)*x-2*a^2*(I*A+B)*ln(cos(d*x+c))/d-a^2*(A-I*B)*tan(d*x+c)/d+1/2*B*(a+I*a*tan(d*x+c))^2/d

Rubi [A] (verified)

Time = 0.12 (sec) , antiderivative size = 80, normalized size of antiderivative = 1.00, number of steps used = 3, number of rules used = 3, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.115, Rules used = {3608, 3558, 3556} \[ \int (a+i a \tan (c+d x))^2 (A+B \tan (c+d x)) \, dx=-\frac {a^2 (A-i B) \tan (c+d x)}{d}-\frac {2 a^2 (B+i A) \log (\cos (c+d x))}{d}+2 a^2 x (A-i B)+\frac {B (a+i a \tan (c+d x))^2}{2 d} \]

[In]

Int[(a + I*a*Tan[c + d*x])^2*(A + B*Tan[c + d*x]),x]

[Out]

2*a^2*(A - I*B)*x - (2*a^2*(I*A + B)*Log[Cos[c + d*x]])/d - (a^2*(A - I*B)*Tan[c + d*x])/d + (B*(a + I*a*Tan[c
 + d*x])^2)/(2*d)

Rule 3556

Int[tan[(c_.) + (d_.)*(x_)], x_Symbol] :> Simp[-Log[RemoveContent[Cos[c + d*x], x]]/d, x] /; FreeQ[{c, d}, x]

Rule 3558

Int[((a_) + (b_.)*tan[(c_.) + (d_.)*(x_)])^2, x_Symbol] :> Simp[(a^2 - b^2)*x, x] + (Dist[2*a*b, Int[Tan[c + d
*x], x], x] + Simp[b^2*(Tan[c + d*x]/d), x]) /; FreeQ[{a, b, c, d}, x]

Rule 3608

Int[((a_) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(m_)*((c_.) + (d_.)*tan[(e_.) + (f_.)*(x_)]), x_Symbol] :> Simp[d*(
(a + b*Tan[e + f*x])^m/(f*m)), x] + Dist[(b*c + a*d)/b, Int[(a + b*Tan[e + f*x])^m, x], x] /; FreeQ[{a, b, c,
d, e, f, m}, x] && NeQ[b*c - a*d, 0] && EqQ[a^2 + b^2, 0] &&  !LtQ[m, 0]

Rubi steps \begin{align*} \text {integral}& = \frac {B (a+i a \tan (c+d x))^2}{2 d}-(-A+i B) \int (a+i a \tan (c+d x))^2 \, dx \\ & = 2 a^2 (A-i B) x-\frac {a^2 (A-i B) \tan (c+d x)}{d}+\frac {B (a+i a \tan (c+d x))^2}{2 d}+\left (2 a^2 (i A+B)\right ) \int \tan (c+d x) \, dx \\ & = 2 a^2 (A-i B) x-\frac {2 a^2 (i A+B) \log (\cos (c+d x))}{d}-\frac {a^2 (A-i B) \tan (c+d x)}{d}+\frac {B (a+i a \tan (c+d x))^2}{2 d} \\ \end{align*}

Mathematica [A] (verified)

Time = 0.49 (sec) , antiderivative size = 58, normalized size of antiderivative = 0.72 \[ \int (a+i a \tan (c+d x))^2 (A+B \tan (c+d x)) \, dx=\frac {a^2 \left (B+4 (i A+B) \log (i+\tan (c+d x))-2 (A-2 i B) \tan (c+d x)-B \tan ^2(c+d x)\right )}{2 d} \]

[In]

Integrate[(a + I*a*Tan[c + d*x])^2*(A + B*Tan[c + d*x]),x]

[Out]

(a^2*(B + 4*(I*A + B)*Log[I + Tan[c + d*x]] - 2*(A - (2*I)*B)*Tan[c + d*x] - B*Tan[c + d*x]^2))/(2*d)

Maple [A] (verified)

Time = 0.06 (sec) , antiderivative size = 76, normalized size of antiderivative = 0.95

method result size
derivativedivides \(\frac {a^{2} \left (-\frac {B \left (\tan ^{2}\left (d x +c \right )\right )}{2}-A \tan \left (d x +c \right )+2 i B \tan \left (d x +c \right )+\frac {\left (2 i A +2 B \right ) \ln \left (1+\tan ^{2}\left (d x +c \right )\right )}{2}+\left (-2 i B +2 A \right ) \arctan \left (\tan \left (d x +c \right )\right )\right )}{d}\) \(76\)
default \(\frac {a^{2} \left (-\frac {B \left (\tan ^{2}\left (d x +c \right )\right )}{2}-A \tan \left (d x +c \right )+2 i B \tan \left (d x +c \right )+\frac {\left (2 i A +2 B \right ) \ln \left (1+\tan ^{2}\left (d x +c \right )\right )}{2}+\left (-2 i B +2 A \right ) \arctan \left (\tan \left (d x +c \right )\right )\right )}{d}\) \(76\)
norman \(\left (-2 i B \,a^{2}+2 A \,a^{2}\right ) x -\frac {\left (-2 i B \,a^{2}+A \,a^{2}\right ) \tan \left (d x +c \right )}{d}-\frac {B \,a^{2} \left (\tan ^{2}\left (d x +c \right )\right )}{2 d}+\frac {\left (i A \,a^{2}+B \,a^{2}\right ) \ln \left (1+\tan ^{2}\left (d x +c \right )\right )}{d}\) \(87\)
parallelrisch \(\frac {-4 i B x \,a^{2} d +2 i A \ln \left (1+\tan ^{2}\left (d x +c \right )\right ) a^{2}+4 A x \,a^{2} d +4 i B \tan \left (d x +c \right ) a^{2}-B \left (\tan ^{2}\left (d x +c \right )\right ) a^{2}-2 A \tan \left (d x +c \right ) a^{2}+2 B \ln \left (1+\tan ^{2}\left (d x +c \right )\right ) a^{2}}{2 d}\) \(98\)
parts \(A \,a^{2} x +\frac {\left (2 i A \,a^{2}+B \,a^{2}\right ) \ln \left (1+\tan ^{2}\left (d x +c \right )\right )}{2 d}+\frac {\left (2 i B \,a^{2}-A \,a^{2}\right ) \left (\tan \left (d x +c \right )-\arctan \left (\tan \left (d x +c \right )\right )\right )}{d}-\frac {B \,a^{2} \left (\frac {\left (\tan ^{2}\left (d x +c \right )\right )}{2}-\frac {\ln \left (1+\tan ^{2}\left (d x +c \right )\right )}{2}\right )}{d}\) \(104\)
risch \(\frac {4 i a^{2} B c}{d}-\frac {4 a^{2} A c}{d}-\frac {2 a^{2} \left (i A \,{\mathrm e}^{2 i \left (d x +c \right )}+3 B \,{\mathrm e}^{2 i \left (d x +c \right )}+i A +2 B \right )}{d \left ({\mathrm e}^{2 i \left (d x +c \right )}+1\right )^{2}}-\frac {2 a^{2} \ln \left ({\mathrm e}^{2 i \left (d x +c \right )}+1\right ) B}{d}-\frac {2 i a^{2} \ln \left ({\mathrm e}^{2 i \left (d x +c \right )}+1\right ) A}{d}\) \(120\)

[In]

int((a+I*a*tan(d*x+c))^2*(A+B*tan(d*x+c)),x,method=_RETURNVERBOSE)

[Out]

1/d*a^2*(-1/2*B*tan(d*x+c)^2-A*tan(d*x+c)+2*I*B*tan(d*x+c)+1/2*(2*B+2*I*A)*ln(1+tan(d*x+c)^2)+(2*A-2*I*B)*arct
an(tan(d*x+c)))

Fricas [A] (verification not implemented)

none

Time = 0.25 (sec) , antiderivative size = 121, normalized size of antiderivative = 1.51 \[ \int (a+i a \tan (c+d x))^2 (A+B \tan (c+d x)) \, dx=-\frac {2 \, {\left ({\left (i \, A + 3 \, B\right )} a^{2} e^{\left (2 i \, d x + 2 i \, c\right )} + {\left (i \, A + 2 \, B\right )} a^{2} + {\left ({\left (i \, A + B\right )} a^{2} e^{\left (4 i \, d x + 4 i \, c\right )} + 2 \, {\left (i \, A + B\right )} a^{2} e^{\left (2 i \, d x + 2 i \, c\right )} + {\left (i \, A + B\right )} a^{2}\right )} \log \left (e^{\left (2 i \, d x + 2 i \, c\right )} + 1\right )\right )}}{d e^{\left (4 i \, d x + 4 i \, c\right )} + 2 \, d e^{\left (2 i \, d x + 2 i \, c\right )} + d} \]

[In]

integrate((a+I*a*tan(d*x+c))^2*(A+B*tan(d*x+c)),x, algorithm="fricas")

[Out]

-2*((I*A + 3*B)*a^2*e^(2*I*d*x + 2*I*c) + (I*A + 2*B)*a^2 + ((I*A + B)*a^2*e^(4*I*d*x + 4*I*c) + 2*(I*A + B)*a
^2*e^(2*I*d*x + 2*I*c) + (I*A + B)*a^2)*log(e^(2*I*d*x + 2*I*c) + 1))/(d*e^(4*I*d*x + 4*I*c) + 2*d*e^(2*I*d*x
+ 2*I*c) + d)

Sympy [A] (verification not implemented)

Time = 0.33 (sec) , antiderivative size = 122, normalized size of antiderivative = 1.52 \[ \int (a+i a \tan (c+d x))^2 (A+B \tan (c+d x)) \, dx=- \frac {2 i a^{2} \left (A - i B\right ) \log {\left (e^{2 i d x} + e^{- 2 i c} \right )}}{d} + \frac {- 2 i A a^{2} - 4 B a^{2} + \left (- 2 i A a^{2} e^{2 i c} - 6 B a^{2} e^{2 i c}\right ) e^{2 i d x}}{d e^{4 i c} e^{4 i d x} + 2 d e^{2 i c} e^{2 i d x} + d} \]

[In]

integrate((a+I*a*tan(d*x+c))**2*(A+B*tan(d*x+c)),x)

[Out]

-2*I*a**2*(A - I*B)*log(exp(2*I*d*x) + exp(-2*I*c))/d + (-2*I*A*a**2 - 4*B*a**2 + (-2*I*A*a**2*exp(2*I*c) - 6*
B*a**2*exp(2*I*c))*exp(2*I*d*x))/(d*exp(4*I*c)*exp(4*I*d*x) + 2*d*exp(2*I*c)*exp(2*I*d*x) + d)

Maxima [A] (verification not implemented)

none

Time = 0.29 (sec) , antiderivative size = 71, normalized size of antiderivative = 0.89 \[ \int (a+i a \tan (c+d x))^2 (A+B \tan (c+d x)) \, dx=-\frac {B a^{2} \tan \left (d x + c\right )^{2} - 4 \, {\left (d x + c\right )} {\left (A - i \, B\right )} a^{2} - 2 \, {\left (i \, A + B\right )} a^{2} \log \left (\tan \left (d x + c\right )^{2} + 1\right ) + 2 \, {\left (A - 2 i \, B\right )} a^{2} \tan \left (d x + c\right )}{2 \, d} \]

[In]

integrate((a+I*a*tan(d*x+c))^2*(A+B*tan(d*x+c)),x, algorithm="maxima")

[Out]

-1/2*(B*a^2*tan(d*x + c)^2 - 4*(d*x + c)*(A - I*B)*a^2 - 2*(I*A + B)*a^2*log(tan(d*x + c)^2 + 1) + 2*(A - 2*I*
B)*a^2*tan(d*x + c))/d

Giac [B] (verification not implemented)

Both result and optimal contain complex but leaf count of result is larger than twice the leaf count of optimal. 214 vs. \(2 (70) = 140\).

Time = 0.38 (sec) , antiderivative size = 214, normalized size of antiderivative = 2.68 \[ \int (a+i a \tan (c+d x))^2 (A+B \tan (c+d x)) \, dx=-\frac {2 \, {\left (i \, A a^{2} e^{\left (4 i \, d x + 4 i \, c\right )} \log \left (e^{\left (2 i \, d x + 2 i \, c\right )} + 1\right ) + B a^{2} e^{\left (4 i \, d x + 4 i \, c\right )} \log \left (e^{\left (2 i \, d x + 2 i \, c\right )} + 1\right ) + 2 i \, A a^{2} e^{\left (2 i \, d x + 2 i \, c\right )} \log \left (e^{\left (2 i \, d x + 2 i \, c\right )} + 1\right ) + 2 \, B a^{2} e^{\left (2 i \, d x + 2 i \, c\right )} \log \left (e^{\left (2 i \, d x + 2 i \, c\right )} + 1\right ) + i \, A a^{2} e^{\left (2 i \, d x + 2 i \, c\right )} + 3 \, B a^{2} e^{\left (2 i \, d x + 2 i \, c\right )} + i \, A a^{2} \log \left (e^{\left (2 i \, d x + 2 i \, c\right )} + 1\right ) + B a^{2} \log \left (e^{\left (2 i \, d x + 2 i \, c\right )} + 1\right ) + i \, A a^{2} + 2 \, B a^{2}\right )}}{d e^{\left (4 i \, d x + 4 i \, c\right )} + 2 \, d e^{\left (2 i \, d x + 2 i \, c\right )} + d} \]

[In]

integrate((a+I*a*tan(d*x+c))^2*(A+B*tan(d*x+c)),x, algorithm="giac")

[Out]

-2*(I*A*a^2*e^(4*I*d*x + 4*I*c)*log(e^(2*I*d*x + 2*I*c) + 1) + B*a^2*e^(4*I*d*x + 4*I*c)*log(e^(2*I*d*x + 2*I*
c) + 1) + 2*I*A*a^2*e^(2*I*d*x + 2*I*c)*log(e^(2*I*d*x + 2*I*c) + 1) + 2*B*a^2*e^(2*I*d*x + 2*I*c)*log(e^(2*I*
d*x + 2*I*c) + 1) + I*A*a^2*e^(2*I*d*x + 2*I*c) + 3*B*a^2*e^(2*I*d*x + 2*I*c) + I*A*a^2*log(e^(2*I*d*x + 2*I*c
) + 1) + B*a^2*log(e^(2*I*d*x + 2*I*c) + 1) + I*A*a^2 + 2*B*a^2)/(d*e^(4*I*d*x + 4*I*c) + 2*d*e^(2*I*d*x + 2*I
*c) + d)

Mupad [B] (verification not implemented)

Time = 7.26 (sec) , antiderivative size = 76, normalized size of antiderivative = 0.95 \[ \int (a+i a \tan (c+d x))^2 (A+B \tan (c+d x)) \, dx=\frac {\ln \left (\mathrm {tan}\left (c+d\,x\right )+1{}\mathrm {i}\right )\,\left (2\,B\,a^2+A\,a^2\,2{}\mathrm {i}\right )}{d}+\frac {\mathrm {tan}\left (c+d\,x\right )\,\left (a^2\,\left (B+A\,1{}\mathrm {i}\right )\,1{}\mathrm {i}+B\,a^2\,1{}\mathrm {i}\right )}{d}-\frac {B\,a^2\,{\mathrm {tan}\left (c+d\,x\right )}^2}{2\,d} \]

[In]

int((A + B*tan(c + d*x))*(a + a*tan(c + d*x)*1i)^2,x)

[Out]

(log(tan(c + d*x) + 1i)*(A*a^2*2i + 2*B*a^2))/d + (tan(c + d*x)*(a^2*(A*1i + B)*1i + B*a^2*1i))/d - (B*a^2*tan
(c + d*x)^2)/(2*d)